//	BioloidBiped.h

#ifndef BIOLOIDBIPED_h
#define BIOLOIDBIPED_h

//	Events which are posted to the application.
#define BBEV_INITIALISED	1
#define BBEV_GAIT_COMPLETED	2	//	The gait has stopped so the robot can start a new move
#define BBEV_STEP			3	//	The robot has taken a further step
#define BBEV_INITIAL_STEP	4	//	The robot has completed an initial half step

void BBInitialise(void (*ReportFn)(int Event));
	//	Call this function once on start-up.
	//	ReportFn can be used to hear about the BBEV_... events.  Set it to NULL if not required.
	
void BBNulReportFn (int Event);
	//	This is the default event reporter.  It does nothing.

void BBHeartBeat(void);
	//	Call this 128 times per second

void BBStop(void);
	//	Call to stop any current motion. Do not assume that the motion will stop immediately, rather the code
	//	must wait for a BBEV_GAIT_COMPLETED event.
	
void BBWalkForwards(int Rpc, int Lpc, int Flags);
	//	Call to walk forwards.
	//	Rpc & Lpc are right & left step percentages.  I.e. (100, 100) is walk straight forward at full speed,
	//	(100, 50) will cause an arc to the left.
	//	Can be called while walking, then just updates Rpc & Lpc.
	//	See BBF_... for Flags values.

char *BBEventText(int Event, char *Text);

//	The following joint IDs are labelled from 0; add 1 to get servo IDs
#define	JID_R_SHDR_FORE		0	//	Shoulder fore/aft servo
#define	JID_L_SHDR_FORE		1
#define	JID_R_SHDR_SPLAY	2	//	Shoulder splay
#define	JID_L_SHDR_SPLAY	3
#define	JID_R_ELBOW			4	//	Elbows are rotated by 90 degrees?!
#define	JID_L_ELBOW			5
#define	JID_R_HIP_YAW		6	//	Yaw movement in hips
#define	JID_L_HIP_YAW		7
#define	JID_R_HIP_SPLAY		8	//	Leg splay
#define	JID_L_HIP_SPLAY		9
#define	JID_R_HIP_FORE		10	//	Hip fore/aft movement
#define	JID_L_HIP_FORE		11
#define	JID_R_KNEE			12	//	Knees
#define	JID_L_KNEE			13
#define	JID_R_ANKL_FORE		14	//	Ankle fore/aft movement
#define	JID_L_ANKL_FORE		15
#define	JID_R_ANKL_ROLL		16	//	Ankle roll movement
#define	JID_L_ANKL_ROLL		17

#define GP_IDLE				0	//	Gait Phase defines
#define GP_INITIALISE		1
#define GP_INITIAL_STEP		2
#define GP_HALF_STEP		3
#define GP_FINAL_STEP		4

//	GaitFlag defines.  Note these are bit-wise values
#define BBF_STOP_REQUESTED	0x01	//	Make true to request the gait to come to a halt. (Better to call BBStop())
#define BBF_REVERSE_STRIDE	0x02	//	Typically the gait leads wit the right foot.  Make this true to lead with the left.

//	The AX-12 manual states that a maximum speed setting of 0x3FF generates 114 RPM
//	This equates to 684 degrees/sec or approx 1.46ms per degree
//	However the AX-12 only moves through 300 degrees, which should take 438ms (assuming infinite acceleration).
//	The 300 degrees equates to an input of 1024 units, so a move of 1024 units should take 438ms.
//	A heartbeat takes 1/128 = 7.8125ms
//	So MoveRequired/NumHeartBeats * 438/7.8125 should yield servo speed to use.
//	438/7.8125 = approx 56.  This is defined below for speed calculations
//	Also, a given move of x (in the range 0-1023) will take 438/(1024 x 7.8125) heartbeats = 0.05475 heartbeats

#define SERVO_SPEED_MULTIPLIER	56
#define MAX_JOINTS				JID_L_ANKL_ROLL+1

typedef struct BB_POSE_STRUCT
{
	int						Ticks;
	unsigned short			Joint[MAX_JOINTS];
	void (*UpdateFn)(struct BB_POSE_STRUCT *Pose);
}	BB_POSE;

int Box[] PROGMEM = {
526,409,298,637,526,
523,409,298,637,523,
520,408,297,637,520,
518,408,296,638,518,
515,408,296,638,515,
512,408,296,638,512,
509,408,296,638,509,
506,408,296,638,506,
504,408,297,637,504,
501,409,298,637,501,
498,409,298,637,498,
526,402,284,644,526,
523,402,283,644,523,
520,401,283,645,520,
518,401,282,645,518,
515,401,282,645,515,
512,401,282,645,512,
509,401,282,645,509,
506,401,282,645,506,
504,401,283,645,504,
501,402,283,644,501,
498,402,284,644,498,
526,396,271,650,526,
523,395,270,651,523,
520,395,270,651,520,
518,395,269,651,518,
515,395,269,652,515,
512,395,269,652,512,
509,395,269,652,509,
506,395,269,651,506,
504,395,270,651,504,
501,395,270,651,501,
498,396,271,650,498,
526,390,259,657,526,
523,390,258,657,523,
521,389,258,657,521,
518,389,257,658,518,
515,389,257,658,515,
512,389,257,658,512,
509,389,257,658,509,
506,389,257,658,506,
503,389,258,657,503,
501,390,258,657,501,
498,390,259,657,498,
527,384,248,663,527,
524,384,247,663,524,
521,384,246,663,521,
518,384,246,664,518,
515,383,246,664,515,
512,383,246,664,512,
509,383,246,664,509,
506,384,246,664,506,
503,384,246,663,503,
500,384,247,663,500,
497,384,248,663,497,
527,379,237,668,527,
524,379,236,669,524,
521,379,236,669,521,
518,378,235,669,518,
515,378,235,669,515,
512,378,235,669,512,
509,378,235,669,509,
506,378,235,669,506,
503,379,236,669,503,
500,379,236,669,500,
497,379,237,668,497,
527,374,227,674,527,
524,374,226,674,524,
521,374,226,674,521,
518,374,225,674,518,
515,373,225,675,515,
512,373,225,675,512,
509,373,225,675,509,
506,374,225,674,506,
503,374,226,674,503,
500,374,226,674,500,
497,374,227,674,497,
527,370,217,679,527,
524,369,216,679,524,
521,369,216,679,521,
518,369,215,680,518,
515,369,215,680,515,
512,369,215,680,512,
509,369,215,680,509,
506,369,215,680,506,
503,369,216,679,503,
500,369,216,679,500,
497,370,217,679,497,
527,365,207,684,527,
524,365,207,684,524,
521,365,206,684,521,
518,364,206,685,518,
515,364,206,685,515,
512,364,206,685,512,
509,364,206,685,509,
506,364,206,685,506,
503,365,206,684,503,
500,365,207,684,500,
497,365,207,684,497,
528,361,198,689,528,
525,361,198,689,525,
521,360,197,689,521,
518,360,197,689,518,
515,360,197,689,515,
512,360,197,689,512,
509,360,197,689,509,
506,360,197,689,506,
503,360,197,689,503,
499,361,198,689,499,
496,361,198,689,496,
528,357,190,693,528,
525,356,189,694,525,
522,356,188,694,522,
518,356,188,694,518,
515,356,188,694,515,
512,356,188,694,512,
509,356,188,694,509,
506,356,188,694,506,
502,356,188,694,502,
499,356,189,694,499,
496,357,190,693,496,
526,406,298,634,526,
523,405,297,635,523,
520,405,296,635,520,
518,405,295,635,518,
515,405,295,635,515,
512,404,295,636,512,
509,405,295,635,509,
506,405,295,635,506,
504,405,296,635,504,
501,405,297,635,501,
498,406,298,634,498,
526,399,283,641,526,
523,398,283,642,523,
520,398,282,642,520,
518,398,281,642,518,
515,398,281,643,515,
512,398,281,643,512,
509,398,281,643,509,
506,398,281,642,506,
504,398,282,642,504,
501,398,283,642,501,
498,399,283,641,498,
526,393,270,648,526,
523,392,270,648,523,
520,392,269,649,520,
518,392,269,649,518,
515,391,268,649,515,
512,391,268,649,512,
509,391,268,649,509,
506,392,269,649,506,
504,392,269,649,504,
501,392,270,648,501,
498,393,270,648,498,
526,387,258,654,526,
523,386,258,655,523,
521,386,257,655,521,
518,386,257,655,518,
515,386,256,655,515,
512,386,256,655,512,
509,386,256,655,509,
506,386,257,655,506,
503,386,257,655,503,
501,386,258,655,501,
498,387,258,654,498,
527,381,247,660,527,
524,381,246,660,524,
521,381,246,661,521,
518,380,245,661,518,
515,380,245,661,515,
512,380,245,661,512,
509,380,245,661,509,
506,380,245,661,506,
503,381,246,661,503,
500,381,246,660,500,
497,381,247,660,497,
527,376,236,666,527,
524,376,236,666,524,
521,375,235,666,521,
518,375,235,667,518,
515,375,234,667,515,
512,375,234,667,512,
509,375,234,667,509,
506,375,235,667,506,
503,375,235,666,503,
500,376,236,666,500,
497,376,236,666,497,
527,371,226,671,527,
524,371,225,671,524,
521,370,225,672,521,
518,370,224,672,518,
515,370,224,672,515,
512,370,224,672,512,
509,370,224,672,509,
506,370,224,672,506,
503,370,225,672,503,
500,371,225,671,500,
497,371,226,671,497,
527,366,216,676,527,
524,366,216,676,524,
521,366,215,677,521,
518,366,215,677,518,
515,365,214,677,515,
512,365,214,677,512,
509,365,214,677,509,
506,366,215,677,506,
503,366,215,677,503,
500,366,216,676,500,
497,366,216,676,497,
527,362,207,681,527,
524,361,206,681,524,
521,361,206,682,521,
518,361,205,682,518,
515,361,205,682,515,
512,361,205,682,512,
509,361,205,682,509,
506,361,205,682,506,
503,361,206,682,503,
500,361,206,681,500,
497,362,207,681,497,
528,357,198,686,528,
525,357,197,686,525,
521,357,197,686,521,
518,357,196,686,518,
515,357,196,687,515,
512,357,196,687,512,
509,357,196,687,509,
506,357,196,686,506,
503,357,197,686,503,
499,357,197,686,499,
496,357,198,686,496,
528,353,189,690,528,
525,353,188,691,525,
522,353,188,691,522,
518,353,187,691,518,
515,352,187,691,515,
512,352,187,691,512,
509,352,187,691,509,
506,353,187,691,506,
502,353,188,691,502,
499,353,188,691,499,
496,353,189,690,496,
526,403,297,632,526,
523,402,296,632,523,
520,402,295,633,520,
518,402,295,633,518,
515,401,294,633,515,
512,401,294,633,512,
509,401,294,633,509,
506,402,295,633,506,
504,402,295,633,504,
501,402,296,632,501,
498,403,297,632,498,
526,396,283,639,526,
523,395,282,639,523,
520,395,281,640,520,
518,395,281,640,518,
515,395,280,640,515,
512,395,280,640,512,
509,395,280,640,509,
506,395,281,640,506,
504,395,281,640,504,
501,395,282,639,501,
498,396,283,639,498,
526,389,270,646,526,
523,389,269,646,523,
520,389,268,646,520,
518,388,268,647,518,
515,388,268,647,515,
512,388,268,647,512,
509,388,268,647,509,
506,388,268,647,506,
504,389,268,646,504,
501,389,269,646,501,
498,389,270,646,498,
526,384,258,652,526,
523,383,257,652,523,
521,383,256,652,521,
518,383,256,653,518,
515,383,256,653,515,
512,382,256,653,512,
509,383,256,653,509,
506,383,256,653,506,
503,383,256,652,503,
501,383,257,652,501,
498,384,258,652,498,
527,378,246,658,527,
524,378,246,658,524,
521,377,245,658,521,
518,377,245,658,518,
515,377,245,658,515,
512,377,244,659,512,
509,377,245,658,509,
506,377,245,658,506,
503,377,245,658,503,
500,378,246,658,500,
497,378,246,658,497,
527,373,236,663,527,
524,372,235,663,524,
521,372,235,664,521,
518,372,234,664,518,
515,372,234,664,515,
512,372,234,664,512,
509,372,234,664,509,
506,372,234,664,506,
503,372,235,664,503,
500,372,235,663,500,
497,373,236,663,497,
527,368,226,668,527,
524,367,225,669,524,
521,367,224,669,521,
518,367,224,669,518,
515,367,224,669,515,
512,367,224,669,512,
509,367,224,669,509,
506,367,224,669,506,
503,367,224,669,503,
500,367,225,669,500,
497,368,226,668,497,
527,363,216,673,527,
524,363,215,674,524,
521,362,215,674,521,
518,362,214,674,518,
515,362,214,674,515,
512,362,214,674,512,
509,362,214,674,509,
506,362,214,674,506,
503,362,215,674,503,
500,363,215,674,500,
497,363,216,673,497,
527,358,206,678,527,
524,358,206,678,524,
521,358,205,679,521,
518,358,205,679,518,
515,358,205,679,515,
512,358,204,679,512,
509,358,205,679,509,
506,358,205,679,506,
503,358,205,679,503,
500,358,206,678,500,
497,358,206,678,497,
528,354,197,683,528,
525,354,197,683,525,
521,353,196,683,521,
518,353,196,684,518,
515,353,196,684,515,
512,353,195,684,512,
509,353,196,684,509,
506,353,196,684,506,
503,353,196,683,503,
499,354,197,683,499,
496,354,197,683,496,
528,350,188,687,528,
525,350,188,688,525,
522,349,187,688,522,
518,349,187,688,518,
515,349,187,688,515,
512,349,187,688,512,
509,349,187,688,509,
506,349,187,688,506,
502,349,187,688,502,
499,350,188,688,499,
496,350,188,687,496,
526,400,296,629,526,
523,399,295,630,523,
520,399,295,630,520,
518,399,294,630,518,
515,398,294,631,515,
512,398,294,631,512,
509,398,294,631,509,
506,399,294,630,506,
504,399,295,630,504,
501,399,295,630,501,
498,400,296,629,498,
526,393,282,636,526,
523,392,281,637,523,
520,392,281,637,520,
518,392,280,637,518,
515,392,280,638,515,
512,392,280,638,512,
509,392,280,638,509,
506,392,280,637,506,
504,392,281,637,504,
501,392,281,637,501,
498,393,282,636,498,
526,386,269,643,526,
523,386,269,643,523,
520,386,268,644,520,
518,385,268,644,518,
515,385,267,644,515,
512,385,267,644,512,
509,385,267,644,509,
506,385,268,644,506,
504,386,268,644,504,
501,386,269,643,501,
498,386,269,643,498,
526,380,257,649,526,
523,380,257,649,523,
521,380,256,650,521,
518,380,256,650,518,
515,379,255,650,515,
512,379,255,650,512,
509,379,255,650,509,
506,380,256,650,506,
503,380,256,650,503,
501,380,257,649,501,
498,380,257,649,498,
527,375,246,655,527,
524,375,245,655,524,
521,374,245,655,521,
518,374,244,656,518,
515,374,244,656,515,
512,374,244,656,512,
509,374,244,656,509,
506,374,244,656,506,
503,374,245,655,503,
500,375,245,655,500,
497,375,246,655,497,
527,370,235,660,527,
524,369,235,661,524,
521,369,234,661,521,
518,369,234,661,518,
515,369,233,661,515,
512,369,233,661,512,
509,369,233,661,509,
506,369,234,661,506,
503,369,234,661,503,
500,369,235,661,500,
497,370,235,660,497,
527,365,225,665,527,
524,364,224,666,524,
521,364,224,666,521,
518,364,224,666,518,
515,364,223,666,515,
512,364,223,666,512,
509,364,223,666,509,
506,364,224,666,506,
503,364,224,666,503,
500,364,224,666,500,
497,365,225,665,497,
527,360,215,670,527,
524,359,215,671,524,
521,359,214,671,521,
518,359,214,671,518,
515,359,214,671,515,
512,359,213,671,512,
509,359,214,671,509,
506,359,214,671,506,
503,359,214,671,503,
500,359,215,671,500,
497,360,215,670,497,
527,355,206,675,527,
524,355,205,676,524,
521,355,205,676,521,
518,354,204,676,518,
515,354,204,676,515,
512,354,204,676,512,
509,354,204,676,509,
506,354,204,676,506,
503,355,205,676,503,
500,355,205,676,500,
497,355,206,675,497,
528,351,197,680,528,
525,350,196,680,525,
521,350,196,680,521,
518,350,195,681,518,
515,350,195,681,515,
512,350,195,681,512,
509,350,195,681,509,
506,350,195,681,506,
503,350,196,680,503,
499,350,196,680,499,
496,351,197,680,496,
528,346,188,684,528,
525,346,187,685,525,
522,346,187,685,522,
518,346,187,685,518,
515,346,186,685,515,
512,346,186,685,512,
509,346,186,685,509,
506,346,187,685,506,
502,346,187,685,502,
499,346,187,685,499,
496,346,188,684,496,
526,397,296,627,526,
523,396,295,627,523,
520,396,294,628,520,
518,396,294,628,518,
515,396,294,628,515,
512,395,293,628,512,
509,396,294,628,509,
506,396,294,628,506,
504,396,294,628,504,
501,396,295,627,501,
498,397,296,627,498,
526,390,282,634,526,
523,389,281,634,523,
520,389,280,635,520,
518,389,280,635,518,
515,389,280,635,515,
512,389,280,635,512,
509,389,280,635,509,
506,389,280,635,506,
504,389,280,635,504,
501,389,281,634,501,
498,390,282,634,498,
526,383,269,640,526,
523,383,268,641,523,
520,383,268,641,520,
518,382,267,641,518,
515,382,267,641,515,
512,382,267,641,512,
509,382,267,641,509,
506,382,267,641,506,
504,383,268,641,504,
501,383,268,641,501,
498,383,269,640,498,
526,377,257,646,526,
523,377,256,647,523,
521,377,256,647,521,
518,377,255,647,518,
515,376,255,647,515,
512,376,255,647,512,
509,376,255,647,509,
506,377,255,647,506,
503,377,256,647,503,
501,377,256,647,501,
498,377,257,646,498,
527,372,246,652,527,
524,371,245,652,524,
521,371,245,653,521,
518,371,244,653,518,
515,371,244,653,515,
512,371,244,653,512,
509,371,244,653,509,
506,371,244,653,506,
503,371,245,653,503,
500,371,245,652,500,
497,372,246,652,497,
527,367,235,657,527,
524,366,234,658,524,
521,366,234,658,521,
518,366,233,658,518,
515,366,233,658,515,
512,366,233,658,512,
509,366,233,658,509,
506,366,233,658,506,
503,366,234,658,503,
500,366,234,658,500,
497,367,235,657,497,
527,361,225,663,527,
524,361,224,663,524,
521,361,224,663,521,
518,361,223,663,518,
515,361,223,663,515,
512,361,223,664,512,
509,361,223,663,509,
506,361,223,663,506,
503,361,224,663,503,
500,361,224,663,500,
497,361,225,663,497,
527,357,215,667,527,
524,356,214,668,524,
521,356,214,668,521,
518,356,214,668,518,
515,356,213,668,515,
512,356,213,668,512,
509,356,213,668,509,
506,356,214,668,506,
503,356,214,668,503,
500,356,214,668,500,
497,357,215,667,497,
527,352,206,672,527,
524,352,205,673,524,
521,351,205,673,521,
518,351,204,673,518,
515,351,204,673,515,
512,351,204,673,512,
509,351,204,673,509,
506,351,204,673,506,
503,351,205,673,503,
500,352,205,673,500,
497,352,206,672,497,
528,347,197,677,528,
525,347,196,677,525,
521,347,196,677,521,
518,347,195,678,518,
515,347,195,678,515,
512,347,195,678,512,
509,347,195,678,509,
506,347,195,678,506,
503,347,196,677,503,
499,347,196,677,499,
496,347,197,677,496,
528,343,188,681,528,
525,343,187,682,525,
522,343,187,682,522,
518,342,186,682,518,
515,342,186,682,515,
512,342,186,682,512,
509,342,186,682,509,
506,342,186,682,506,
502,343,187,682,502,
499,343,187,682,499,
496,343,188,681,496,
526,394,296,624,526,
523,393,295,625,523,
520,393,294,625,520,
518,393,294,625,518,
515,393,293,625,515,
512,393,293,625,512,
509,393,293,625,509,
506,393,294,625,506,
504,393,294,625,504,
501,393,295,625,501,
498,394,296,624,498,
526,387,282,631,526,
523,387,281,631,523,
520,386,280,632,520,
518,386,280,632,518,
515,386,280,632,515,
512,386,280,632,512,
509,386,280,632,509,
506,386,280,632,506,
504,386,280,632,504,
501,387,281,631,501,
498,387,282,631,498,
526,381,269,637,526,
523,380,268,638,523,
520,380,268,638,520,
518,380,267,638,518,
515,379,267,639,515,
512,379,267,639,512,
509,379,267,639,509,
506,380,267,638,506,
504,380,268,638,504,
501,380,268,638,501,
498,381,269,637,498,
526,375,257,643,526,
523,374,256,644,523,
521,374,256,644,521,
518,374,255,644,518,
515,374,255,644,515,
512,373,255,645,512,
509,374,255,644,509,
506,374,255,644,506,
503,374,256,644,503,
501,374,256,644,501,
498,375,257,643,498,
527,369,246,649,527,
524,369,245,649,524,
521,368,244,650,521,
518,368,244,650,518,
515,368,244,650,515,
512,368,244,650,512,
509,368,244,650,509,
506,368,244,650,506,
503,368,244,650,503,
500,369,245,649,500,
497,369,246,649,497,
527,364,235,654,527,
524,363,234,655,524,
521,363,234,655,521,
518,363,233,655,518,
515,363,233,655,515,
512,363,233,655,512,
509,363,233,655,509,
506,363,233,655,506,
503,363,234,655,503,
500,363,234,655,500,
497,364,235,654,497,
527,358,225,660,527,
524,358,224,660,524,
521,358,224,660,521,
518,358,223,660,518,
515,358,223,660,515,
512,357,223,661,512,
509,358,223,660,509,
506,358,223,660,506,
503,358,224,660,503,
500,358,224,660,500,
497,358,225,660,497,
527,354,215,664,527,
524,353,214,665,524,
521,353,214,665,521,
518,353,213,665,518,
515,353,213,665,515,
512,353,213,665,512,
509,353,213,665,509,
506,353,213,665,506,
503,353,214,665,503,
500,353,214,665,500,
497,354,215,664,497,
527,349,206,669,527,
524,349,205,669,524,
521,348,204,670,521,
518,348,204,670,518,
515,348,204,670,515,
512,348,204,670,512,
509,348,204,670,509,
506,348,204,670,506,
503,348,204,670,503,
500,349,205,669,500,
497,349,206,669,497,
528,344,197,674,528,
525,344,196,674,525,
521,344,195,674,521,
518,344,195,674,518,
515,343,195,675,515,
512,343,195,675,512,
509,343,195,675,509,
506,344,195,674,506,
503,344,195,674,503,
499,344,196,674,499,
496,344,197,674,496,
528,340,188,678,528,
525,340,187,678,525,
522,339,187,679,522,
518,339,186,679,518,
515,339,186,679,515,
512,339,186,679,512,
509,339,186,679,509,
506,339,186,679,506,
502,339,187,679,502,
499,340,187,678,499,
496,340,188,678,496,
526,391,296,621,526,
523,391,295,622,523,
520,390,294,622,520,
518,390,294,622,518,
515,390,294,622,515,
512,390,293,623,512,
509,390,294,622,509,
506,390,294,622,506,
504,390,294,622,504,
501,391,295,622,501,
498,391,296,621,498,
526,384,282,628,526,
523,384,281,629,523,
520,383,280,629,520,
518,383,280,629,518,
515,383,280,629,515,
512,383,280,629,512,
509,383,280,629,509,
506,383,280,629,506,
504,383,280,629,504,
501,384,281,629,501,
498,384,282,628,498,
526,378,269,635,526,
523,377,268,635,523,
520,377,268,635,520,
518,377,267,636,518,
515,377,267,636,515,
512,377,267,636,512,
509,377,267,636,509,
506,377,267,636,506,
504,377,268,635,504,
501,377,268,635,501,
498,378,269,635,498,
526,372,257,641,526,
523,371,256,641,523,
521,371,256,641,521,
518,371,255,641,518,
515,371,255,642,515,
512,371,255,642,512,
509,371,255,642,509,
506,371,255,641,506,
503,371,256,641,503,
501,371,256,641,501,
498,372,257,641,498,
527,366,246,646,527,
524,366,245,647,524,
521,365,245,647,521,
518,365,244,647,518,
515,365,244,647,515,
512,365,244,647,512,
509,365,244,647,509,
506,365,244,647,506,
503,365,245,647,503,
500,366,245,647,500,
497,366,246,646,497,
527,361,235,651,527,
524,360,234,652,524,
521,360,234,652,521,
518,360,233,652,518,
515,360,233,652,515,
512,360,233,652,512,
509,360,233,652,509,
506,360,233,652,506,
503,360,234,652,503,
500,360,234,652,500,
497,361,235,651,497,
527,355,225,657,527,
524,355,224,657,524,
521,355,224,657,521,
518,355,223,657,518,
515,355,223,657,515,
512,354,223,657,512,
509,355,223,657,509,
506,355,223,657,506,
503,355,224,657,503,
500,355,224,657,500,
497,355,225,657,497,
527,351,215,661,527,
524,350,214,662,524,
521,350,214,662,521,
518,350,214,662,518,
515,350,213,662,515,
512,350,213,662,512,
509,350,213,662,509,
506,350,214,662,506,
503,350,214,662,503,
500,350,214,662,500,
497,351,215,661,497,
527,346,206,666,527,
524,345,205,666,524,
521,345,205,667,521,
518,345,204,667,518,
515,345,204,667,515,
512,345,204,667,512,
509,345,204,667,509,
506,345,204,667,506,
503,345,205,667,503,
500,345,205,666,500,
497,346,206,666,497,
528,341,197,671,528,
525,341,196,671,525,
521,341,196,671,521,
518,340,195,671,518,
515,340,195,671,515,
512,340,195,671,512,
509,340,195,671,509,
506,340,195,671,506,
503,341,196,671,503,
499,341,196,671,499,
496,341,197,671,496,
528,337,188,675,528,
525,336,187,675,525,
522,336,187,675,522,
518,336,186,676,518,
515,336,186,676,515,
512,336,186,676,512,
509,336,186,676,509,
506,336,186,676,506,
502,336,187,675,502,
499,336,187,675,499,
496,337,188,675,496,
526,389,296,618,526,
523,388,295,619,523,
520,388,295,619,520,
518,388,294,619,518,
515,387,294,620,515,
512,387,294,620,512,
509,387,294,620,509,
506,388,294,619,506,
504,388,295,619,504,
501,388,295,619,501,
498,389,296,618,498,
526,382,282,625,526,
523,381,281,626,523,
520,381,281,626,520,
518,381,280,626,518,
515,380,280,626,515,
512,380,280,626,512,
509,380,280,626,509,
506,381,280,626,506,
504,381,281,626,504,
501,381,281,626,501,
498,382,282,625,498,
526,375,269,632,526,
523,375,269,632,523,
520,374,268,632,520,
518,374,268,633,518,
515,374,267,633,515,
512,374,267,633,512,
509,374,267,633,509,
506,374,268,633,506,
504,374,268,632,504,
501,375,269,632,501,
498,375,269,632,498,
526,369,257,638,526,
523,369,257,638,523,
521,368,256,638,521,
518,368,256,638,518,
515,368,255,639,515,
512,368,255,639,512,
509,368,255,639,509,
506,368,256,638,506,
503,368,256,638,503,
501,369,257,638,501,
498,369,257,638,498,
527,363,246,643,527,
524,363,245,643,524,
521,363,245,644,521,
518,362,244,644,518,
515,362,244,644,515,
512,362,244,644,512,
509,362,244,644,509,
506,362,244,644,506,
503,363,245,644,503,
500,363,245,643,500,
497,363,246,643,497,
527,358,235,648,527,
524,357,235,649,524,
521,357,234,649,521,
518,357,234,649,518,
515,357,233,649,515,
512,357,233,649,512,
509,357,233,649,509,
506,357,234,649,506,
503,357,234,649,503,
500,357,235,649,500,
497,358,235,648,497,
527,353,225,653,527,
524,352,224,654,524,
521,352,224,654,521,
518,352,224,654,518,
515,352,223,654,515,
512,352,223,654,512,
509,352,223,654,509,
506,352,224,654,506,
503,352,224,654,503,
500,352,224,654,500,
497,353,225,653,497,
527,348,215,658,527,
524,347,215,659,524,
521,347,214,659,521,
518,347,214,659,518,
515,347,214,659,515,
512,347,213,659,512,
509,347,214,659,509,
506,347,214,659,506,
503,347,214,659,503,
500,347,215,659,500,
497,348,215,658,497,
527,343,206,663,527,
524,342,205,663,524,
521,342,205,663,521,
518,342,204,664,518,
515,342,204,664,515,
512,342,204,664,512,
509,342,204,664,509,
506,342,204,664,506,
503,342,205,663,503,
500,342,205,663,500,
497,343,206,663,497,
528,338,197,667,528,
525,338,196,668,525,
521,338,196,668,521,
518,337,195,668,518,
515,337,195,668,515,
512,337,195,668,512,
509,337,195,668,509,
506,337,195,668,506,
503,338,196,668,503,
499,338,196,668,499,
496,338,197,667,496,
528,334,188,672,528,
525,333,187,672,525,
522,333,187,672,522,
518,333,187,672,518,
515,333,186,672,515,
512,333,186,672,512,
509,333,186,672,509,
506,333,187,672,506,
502,333,187,672,502,
499,333,187,672,499,
496,334,188,672,496,
526,386,297,615,526,
523,386,296,616,523,
520,385,295,616,520,
518,385,295,616,518,
515,385,294,617,515,
512,385,294,617,512,
509,385,294,617,509,
506,385,295,616,506,
504,385,295,616,504,
501,386,296,616,501,
498,386,297,615,498,
526,379,283,622,526,
523,379,282,623,523,
520,378,281,623,520,
518,378,281,623,518,
515,378,280,623,515,
512,378,280,623,512,
509,378,280,623,509,
506,378,281,623,506,
504,378,281,623,504,
501,379,282,623,501,
498,379,283,622,498,
526,372,270,629,526,
523,372,269,629,523,
520,372,268,629,520,
518,371,268,630,518,
515,371,268,630,515,
512,371,268,630,512,
509,371,268,630,509,
506,371,268,630,506,
504,372,268,629,504,
501,372,269,629,501,
498,372,270,629,498,
526,366,258,634,526,
523,366,257,635,523,
521,366,256,635,521,
518,365,256,635,518,
515,365,256,635,515,
512,365,256,636,512,
509,365,256,635,509,
506,365,256,635,506,
503,366,256,635,503,
501,366,257,635,501,
498,366,258,634,498,
527,360,246,640,527,
524,360,246,640,524,
521,360,245,641,521,
518,360,245,641,518,
515,360,245,641,515,
512,359,244,641,512,
509,360,245,641,509,
506,360,245,641,506,
503,360,245,641,503,
500,360,246,640,500,
497,360,246,640,497,
527,355,236,645,527,
524,355,235,646,524,
521,354,235,646,521,
518,354,234,646,518,
515,354,234,646,515,
512,354,234,646,512,
509,354,234,646,509,
506,354,234,646,506,
503,354,235,646,503,
500,355,235,646,500,
497,355,236,645,497,
527,350,226,650,527,
524,349,225,651,524,
521,349,224,651,521,
518,349,224,651,518,
515,349,224,651,515,
512,349,224,651,512,
509,349,224,651,509,
506,349,224,651,506,
503,349,224,651,503,
500,349,225,651,500,
497,350,226,650,497,
527,345,216,655,527,
524,344,215,655,524,
521,344,215,656,521,
518,344,214,656,518,
515,344,214,656,515,
512,344,214,656,512,
509,344,214,656,509,
506,344,214,656,506,
503,344,215,656,503,
500,344,215,655,500,
497,345,216,655,497,
527,340,206,660,527,
524,340,206,660,524,
521,339,205,660,521,
518,339,205,660,518,
515,339,205,660,515,
512,339,204,660,512,
509,339,205,660,509,
506,339,205,660,506,
503,339,205,660,503,
500,340,206,660,500,
497,340,206,660,497,
528,335,197,664,528,
525,335,197,664,525,
521,335,196,665,521,
518,334,196,665,518,
515,334,196,665,515,
512,334,195,665,512,
509,334,196,665,509,
506,334,196,665,506,
503,335,196,665,503,
499,335,197,664,499,
496,335,197,664,496,
528,331,188,668,528,
525,330,188,668,525,
522,330,187,669,522,
518,330,187,669,518,
515,330,187,669,515,
512,330,187,669,512,
509,330,187,669,509,
506,330,187,669,506,
502,330,187,669,502,
499,330,188,668,499,
496,331,188,668,496,
526,384,298,612,526,
523,383,297,613,523,
520,383,296,613,520,
518,383,295,613,518,
515,383,295,613,515,
512,382,295,614,512,
509,383,295,613,509,
506,383,295,613,506,
504,383,296,613,504,
501,383,297,613,501,
498,384,298,612,498,
526,377,283,619,526,
523,376,283,620,523,
520,376,282,620,520,
518,376,281,620,518,
515,375,281,620,515,
512,375,281,620,512,
509,375,281,620,509,
506,376,281,620,506,
504,376,282,620,504,
501,376,283,620,501,
498,377,283,619,498,
526,370,270,625,526,
523,370,270,626,523,
520,369,269,626,520,
518,369,269,626,518,
515,369,268,627,515,
512,369,268,627,512,
509,369,268,627,509,
506,369,269,626,506,
504,369,269,626,504,
501,370,270,626,501,
498,370,270,625,498,
526,364,258,631,526,
523,363,258,632,523,
521,363,257,632,521,
518,363,257,632,518,
515,363,256,632,515,
512,363,256,632,512,
509,363,256,632,509,
506,363,257,632,506,
503,363,257,632,503,
501,363,258,632,501,
498,364,258,631,498,
527,358,247,637,527,
524,358,246,637,524,
521,357,246,637,521,
518,357,245,638,518,
515,357,245,638,515,
512,357,245,638,512,
509,357,245,638,509,
506,357,245,638,506,
503,357,246,637,503,
500,358,246,637,500,
497,358,247,637,497,
527,352,236,642,527,
524,352,236,642,524,
521,352,235,643,521,
518,351,235,643,518,
515,351,234,643,515,
512,351,234,643,512,
509,351,234,643,509,
506,351,235,643,506,
503,352,235,643,503,
500,352,236,642,500,
497,352,236,642,497,
527,347,226,647,527,
524,347,225,647,524,
521,346,225,648,521,
518,346,224,648,518,
515,346,224,648,515,
512,346,224,648,512,
509,346,224,648,509,
506,346,224,648,506,
503,346,225,648,503,
500,347,225,647,500,
497,347,226,647,497,
527,342,216,652,527,
524,342,216,652,524,
521,341,215,652,521,
518,341,215,652,518,
515,341,214,653,515,
512,341,214,653,512,
509,341,214,653,509,
506,341,215,652,506,
503,341,215,652,503,
500,342,216,652,500,
497,342,216,652,497,
527,337,207,656,527,
524,337,206,657,524,
521,336,206,657,521,
518,336,205,657,518,
515,336,205,657,515,
512,336,205,657,512,
509,336,205,657,509,
506,336,205,657,506,
503,336,206,657,503,
500,337,206,657,500,
497,337,207,656,497,
528,332,198,661,528,
525,332,197,661,525,
521,332,197,661,521,
518,332,196,661,518,
515,331,196,661,515,
512,331,196,661,512,
509,331,196,661,509,
506,332,196,661,506,
503,332,197,661,503,
499,332,197,661,499,
496,332,198,661,496,
528,328,189,665,528,
525,327,188,665,525,
522,327,188,665,522,
518,327,187,665,518,
515,327,187,666,515,
512,327,187,666,512,
509,327,187,666,509,
506,327,187,665,506,
502,327,188,665,502,
499,327,188,665,499,
496,328,189,665,496,
526,381,298,609,526,
523,381,298,609,523,
520,381,297,610,520,
518,380,296,610,518,
515,380,296,610,515,
512,380,296,610,512,
509,380,296,610,509,
506,380,296,610,506,
504,381,297,610,504,
501,381,298,609,501,
498,381,298,609,498,
526,374,284,616,526,
523,374,283,616,523,
520,373,283,617,520,
518,373,282,617,518,
515,373,282,617,515,
512,373,282,617,512,
509,373,282,617,509,
506,373,282,617,506,
504,373,283,617,504,
501,374,283,616,501,
498,374,284,616,498,
526,368,271,622,526,
523,367,270,623,523,
520,367,270,623,520,
518,367,269,623,518,
515,366,269,623,515,
512,366,269,623,512,
509,366,269,623,509,
506,367,269,623,506,
504,367,270,623,504,
501,367,270,623,501,
498,368,271,622,498,
526,361,259,628,526,
523,361,258,628,523,
521,361,258,629,521,
518,360,257,629,518,
515,360,257,629,515,
512,360,257,629,512,
509,360,257,629,509,
506,360,257,629,506,
503,361,258,629,503,
501,361,258,628,501,
498,361,259,628,498,
527,355,248,634,527,
524,355,247,634,524,
521,355,246,634,521,
518,354,246,634,518,
515,354,246,635,515,
512,354,246,635,512,
509,354,246,635,509,
506,354,246,634,506,
503,355,246,634,503,
500,355,247,634,500,
497,355,248,634,497,
527,350,237,639,527,
524,349,236,639,524,
521,349,236,639,521,
518,349,235,640,518,
515,349,235,640,515,
512,349,235,640,512,
509,349,235,640,509,
506,349,235,640,506,
503,349,236,639,503,
500,349,236,639,500,
497,350,237,639,497,
527,344,227,644,527,
524,344,226,644,524,
521,344,226,644,521,
518,344,225,644,518,
515,343,225,645,515,
512,343,225,645,512,
509,343,225,645,509,
506,344,225,644,506,
503,344,226,644,503,
500,344,226,644,500,
497,344,227,644,497,
527,339,217,648,527,
524,339,216,649,524,
521,339,216,649,521,
518,338,215,649,518,
515,338,215,649,515,
512,338,215,649,512,
509,338,215,649,509,
506,338,215,649,506,
503,339,216,649,503,
500,339,216,649,500,
497,339,217,648,497,
527,334,207,653,527,
524,334,207,653,524,
521,334,206,653,521,
518,333,206,654,518,
515,333,206,654,515,
512,333,206,654,512,
509,333,206,654,509,
506,333,206,654,506,
503,334,206,653,503,
500,334,207,653,500,
497,334,207,653,497,
528,329,198,657,528,
525,329,198,657,525,
521,329,197,658,521,
518,329,197,658,518,
515,329,197,658,515,
512,329,197,658,512,
509,329,197,658,509,
506,329,197,658,506,
503,329,197,658,503,
499,329,198,657,499,
496,329,198,657,496,
528,325,190,661,528,
525,324,189,662,525,
522,324,188,662,522,
518,324,188,662,518,
515,324,188,662,515,
512,324,188,662,512,
509,324,188,662,509,
506,324,188,662,506,
502,324,188,662,502,
499,324,189,662,499,
496,325,190,661,496
};

#endif